package com.gree.scmservice.dao;

import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by 180474 on 2020/11/16.
 */
@Repository
public class LoginDao {
    @Autowired
    private Dao dao;

    public List<Record> getCompList(){
        Sql sql = Sqls.create("select comp,dsca,ctyp from Smcom00 order by ctyp asc");
        sql.setCallback(Sqls.callback.entities());
        sql.setEntity(dao.getEntity(Record.class));
        List<Record> list=dao.execute(sql).getList(Record.class);
        return list;
    }

    public List<Record> getCompAndNameList(String[] comps){

        Sql sql = Sqls.create("select comp,dsca from smcom09 where comp in (@comp)");
        sql.setParam("comp",comps);
        sql.setCallback(Sqls.callback.entities());
        sql.setEntity(dao.getEntity(Record.class));
        List<Record> list=dao.execute(sql).getList(Record.class);
        return list;
    }


}
